void Flow2AuthWidget::startAuth(Account *account)
{
- Flow2Auth *oldAuth = _asyncAuth.take();
- if(oldAuth)
+ const auto oldAuth = _asyncAuth.release();
+ if (oldAuth) {
oldAuth->deleteLater();
+ }
_statusUpdateSkipCount = 0;
if(account) {
_account = account;
- _asyncAuth.reset(new Flow2Auth(_account, this));
- connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::slotAuthResult, Qt::QueuedConnection);
- connect(_asyncAuth.data(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged);
- connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow);
+ _asyncAuth = std::make_unique<Flow2Auth>(_account, this);
+ connect(_asyncAuth.get(), &Flow2Auth::result, this, &Flow2AuthWidget::slotAuthResult, Qt::QueuedConnection);
+ connect(_asyncAuth.get(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged);
+ connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.get(), &Flow2Auth::slotPollNow);
_asyncAuth->start();
}
}
Flow2AuthWidget::~Flow2AuthWidget() {
// Forget sensitive data
- _asyncAuth.reset();
+ _asyncAuth.reset(nullptr);
}
void Flow2AuthWidget::slotOpenBrowser()
_remnantReadOnlyFolders.clear();
- _discoveryPhase.reset(new DiscoveryPhase);
+ _discoveryPhase = std::make_unique<DiscoveryPhase>();
_discoveryPhase->_leadingAndTrailingSpacesFilesAllowed = _leadingAndTrailingSpacesFilesAllowed;
_discoveryPhase->_account = _account;
_discoveryPhase->_excludes = _excludedFiles.data();
_discoveryPhase->_serverBlacklistedFiles = _account->capabilities().blacklistedFiles();
_discoveryPhase->_ignoreHiddenFiles = ignoreHiddenFiles();
- connect(_discoveryPhase.data(), &DiscoveryPhase::itemDiscovered, this, &SyncEngine::slotItemDiscovered);
- connect(_discoveryPhase.data(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder);
- connect(_discoveryPhase.data(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig);
- connect(_discoveryPhase.data(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) {
+ connect(_discoveryPhase.get(), &DiscoveryPhase::itemDiscovered, this, &SyncEngine::slotItemDiscovered);
+ connect(_discoveryPhase.get(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder);
+ connect(_discoveryPhase.get(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig);
+ connect(_discoveryPhase.get(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) {
Q_EMIT syncError(errorString, errorCategory);
finalize(false);
});
- connect(_discoveryPhase.data(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished);
- connect(_discoveryPhase.data(), &DiscoveryPhase::silentlyExcluded,
+ connect(_discoveryPhase.get(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished);
+ connect(_discoveryPhase.get(), &DiscoveryPhase::silentlyExcluded,
_syncFileStatusTracker.data(), &SyncFileStatusTracker::slotAddSilentlyExcluded);
- connect(_discoveryPhase.data(), &DiscoveryPhase::remnantReadOnlyFolderDiscovered, this, &SyncEngine::remnantReadOnlyFolderDiscovered);
+ connect(_discoveryPhase.get(), &DiscoveryPhase::remnantReadOnlyFolderDiscovered, this, &SyncEngine::remnantReadOnlyFolderDiscovered);
ProcessDirectoryJob *discoveryJob = nullptr;
}();
discoveryJob = new ProcessDirectoryJob(
- _discoveryPhase.data(),
+ _discoveryPhase.get(),
pinState,
path,
singleItemDiscoveryOptions().discoveryDirItem,
{},
localQueryMode,
_journal->keyValueStoreGetInt("last_sync", 0),
- _discoveryPhase.data()
+ _discoveryPhase.get()
);
} else {
discoveryJob = new ProcessDirectoryJob(
- _discoveryPhase.data(),
+ _discoveryPhase.get(),
PinState::AlwaysLocal,
_journal->keyValueStoreGetInt("last_sync", 0),
- _discoveryPhase.data()
+ _discoveryPhase.get()
);
}
_discoveryPhase->startJob(discoveryJob);
connect(discoveryJob, &ProcessDirectoryJob::etag, this, &SyncEngine::slotRootEtagReceived);
- connect(_discoveryPhase.data(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui);
+ connect(_discoveryPhase.get(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui);
}
void SyncEngine::slotFolderDiscovered(bool local, const QString &folder)
_stopWatch.stop();
if (_discoveryPhase) {
- _discoveryPhase.take()->deleteLater();
+ _discoveryPhase.release()->deleteLater();
}
s_anySyncRunning = false;
_syncRunning = false;
} else if (_discoveryPhase) {
// Delete the discovery and all child jobs after ensuring
// it can't finish and start the propagator
- disconnect(_discoveryPhase.data(), nullptr, this, nullptr);
- _discoveryPhase.take()->deleteLater();
+ disconnect(_discoveryPhase.get(), nullptr, this, nullptr);
+ _discoveryPhase.release()->deleteLater();
qCInfo(lcEngine) << "Aborting sync in discovery...";
finalize(false);
}